#include "opensl_engine.h"

static const SLEnvironmentalReverbSettings reverbSettings =
    SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
OpenSl_Engine::OpenSl_Engine()
{
    SLresult result;
    // create engine
   result = slCreateEngine(&engineObject, 0, 0, 0, 0, 0);

    // realize the engine
   result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);

   result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);

   const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
   const SLboolean req[1] = {SL_BOOLEAN_FALSE};
   result = (*engineEngine)->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);

   result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);

   result = (*outputMixObject)->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
           &outputMixEnvironmentalReverb);
   if (SL_RESULT_SUCCESS == result)
   {
       result = (*outputMixEnvironmentalReverb)->SetEnvironmentalReverbProperties(
               outputMixEnvironmentalReverb, &reverbSettings);
   }
}

OpenSl_Engine::~OpenSl_Engine()
{
    (*outputMixObject)->Destroy(outputMixObject);
     outputMixObject = 0;

     (*engineObject)->Destroy(engineObject);
      engineObject = 0;
}

